package de.preiscrawler.parser.media_deal;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.Source;

import de.preiscrawler.AlleAnbieter;
import de.preiscrawler.parser.AbstractParser;
import de.preisrobot.entity.AbstractEntity;
import de.preisrobot.entity.Artikel;
import de.preisrobot.service.internal.PreisRobotParserException;

public class DvdPalaceParserDetail extends AbstractParser<AbstractEntity> {

	@Override
	public int getAnbieter() {
	 
		return AlleAnbieter.DVD_PALACE;
	}

	@Override
	protected void parseStream(List<AbstractEntity> list, InputStream in)
			throws IOException, PreisRobotParserException {
		
		Source source =new Source(in);
		// xpath geht nicht: aber wir wollen das hier:
		///html/body/table/tbody/tr/td/table[3]/tbody/tr/td[3]/table[2]
	
		List<Element> allTables = source.getAllElements("table");
		Element firstTable = allTables.get(1);
		List<Element> innerTbales = firstTable.getAllElements("table");
		Element element = innerTbales.get(2);
		
		List<Element> innerTbales2 = element.getAllElements("table");
		Element contentTable = innerTbales.get(1);
		
		List<Element> allElements = contentTable.getAllElements("tr");
		allElements.remove(1); //Werbung
		for (Element element2 : allElements) {
			List<Element> allElements2 = element2.getAllElements("td");
			for (Element element3 : allElements2) {
				System.out.println(element3.getTextExtractor().toString());
			}
		}
		
		
		 
		
	}

	private boolean isContentTable(Element evtlContent) {
		
		return false;
	}

}
